package com.example.mapper;

import com.example.entity.HealthProfiles;
import com.example.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProfilesMapper {
    /**
     * 查询总数据
     * @return
     */
    @Select("select count(*) from health_profiles")
    public Long count();

    /**
     * 分页查询
     * @param start
     * @param pageSize
     * @return
     */
    @Select("select * from health_profiles limit #{start},#{pageSize}")
    List<HealthProfiles> pag(Integer start, Integer pageSize);

    @Delete("delete from health_profiles where id = #{id}")
    void delete(Integer id);

    /**
     * 更新
     * @param profiles
     */
    void update(HealthProfiles profiles);

    @Select("select * from health_profiles where  id = #{id}")
    HealthProfiles getId(Integer id);

    @Insert("insert into health_profiles(user_id, blood_type, height, weight, bmi, blood_pressure, cholesterol_level, genetic_disorders, create_time, update_time) " +
            "values (#{userId},#{bloodType},#{height},#{weight},#{bmi},#{bloodPressure},#{cholesterolLevel},#{geneticDisorders},#{createTime},#{updateTime})")
    void add(HealthProfiles profiles);
}
